package com.dlwx.firefighting.adapter;

import android.content.Context;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.iarcuschin.simpleratingbar.SimpleRatingBar;
import com.dlwx.firefighting.R;
import com.dlwx.firefighting.bean.VideoBean;
import com.dlwx.firefighting.config.Constant;


/**
 * Created by Administrator on 2017/6/16.
 */

public class VideoAdapter extends ListBaseAdapter<VideoBean> {

    private Context context;

    public VideoAdapter(Context context) {
        super(context);
        this.context = context;

    }

    @Override
    public int getLayoutId() {
        return R.layout.item_video;
    }

    @Override
    public void onBindItemHolder(SuperViewHolder holder, int position) {
        VideoBean bean = getDataList().get(position);
        ImageView image=holder.getView(R.id.image);
        ImageView centerImg=holder.getView(R.id.center_img);
        TextView videoTitleTv=holder.getView(R.id.video_title_tv);
        TextView videoContentTv=holder.getView(R.id.video_content_tv);
        TextView ratingNumTv=holder.getView(R.id.rating_num_tv);
        SimpleRatingBar ratingBar = holder.getView(R.id.rating_bar);
        int type=bean.getType();
        if(type== Constant.VIDEO){
            centerImg.setBackgroundResource(R.mipmap.video_play_normal);
        }else if(type==Constant.MUSIC){
//            centerImg.setBackgroundResource(R.mipmap.music);
        }

        videoTitleTv.setText(bean.getVideo_name());
        videoContentTv.setText(bean.getVideo_describle());
        Glide.with(context).load(bean.getVideo_thumb()).error(R.mipmap.error_small).into(image);
        int score=0;
        try {
             score=Integer.parseInt(bean.getVideo_score());
        }catch (Exception e){
            e.printStackTrace();
            score=0;
        }
       /* SimpleRatingBar.AnimationBuilder builder = ratingBar.getAnimationBuilder()
                .setRatingTarget(score)
                .setDuration(1000)
                .setInterpolator(new BounceInterpolator());
        builder.start();*/
       if(score>0){
           ratingBar.setRating(score);
//           ratingBar.setNumberOfStars(score);
       }
//        ratingBar.setIndicator(false);
        ratingNumTv.setText(bean.getVideo_score()+"分");

    }

}
